home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok15.lha
/
Seafarers_Manual
/
Source
/
ModDemo.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
2KB
|
87 lines
MODULE ModDemo; (* Show execution of module bodies *)
(* From the book "Modula-2 A Seafarer's Manual and Shipyard Guide" *)
(* Page 174 adapted "Amiga M2Modula-2" 12 Mar 1988 *)
FROM InOut IMPORT Write,
WriteLn,
WriteString;
VAR
a : INTEGER;
PROCEDURE DoThreeMod;
VAR
e : REAL; (* local to procedure *)
MODULE M1;
IMPORT e;
EXPORT b,
c;
VAR
b : CARDINAL;
MODULE M2;
IMPORT b;
EXPORT c;
VAR
c : CHAR;
BEGIN (* M2 *) (* b, c visible here *)
b := 0;
c := "X";
END M2;
BEGIN (* M1 *) (* b, c, e visible here *)
b := 0;
c := "Y";
e := 1.2;
END M1;
MODULE M3;
IMPORT a;
EXPORT QUALIFIED b;
VAR
b,
d : REAL;
BEGIN (* M3 *) (* a, M3.b, d visible here *)
a := -1;
b := 3.4;
d := 5.6;
END M3;
BEGIN (* DoThreeMod *) (* a, b, M3.b, c, e visible here *)
a := -1;
b := 0; (* unqualified refers to M1's *)
M1.b := 0; (* optionally qualified reference *)
M3.b := 7.8; (* mandatory qualified reference *)
c := "Z"; (* procedure assignments *)
e := 0.0; (* supersede module bodies *)
WriteLn;
WriteString ("Processing DoThreeMod");
WriteLn;
Write (c);
END DoThreeMod;
BEGIN (* ModDemo *) (* only a visible here *)
WriteLn;
WriteString ("Start Main");
WriteLn;
DoThreeMod;
a := -9;
WriteLn;
WriteString ("Finish Main");
WriteLn; WriteLn;
END ModDemo.